<!--
MyAuth updateLog
By Daen
QQ1330166565

部署更新日志后，域名 + ?skey=软件KEY 即可
 -->
<script src='http://mycdn.daenx.cn/updateLog/js/layui.js' charset='utf-8'></script>
<!DOCTYPE html><html><head><meta charset="utf-8">
<script>
//服务器地址
var server_url = "http://localhost:8080/myauth/";
//错误跳转地址
var error_url = "http://mycdn.daenx.cn/error.html";
function timestampToTime(timestamp) {
	var date = new Date(timestamp * 1000);
	var Y = date.getFullYear() + '-';
	var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
	var D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
	var h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
	var m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
	var s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
	return Y+M+D+h+m+s;
}
function myReplace(sInput, sChar, sReplaceChar) {
	if(sInput==""||sInput==undefined) {
        return "";
    }
	var oReg =new RegExp(sChar,"g");
	return sInput.replace(oReg, sReplaceChar);
}
function getQueryVariable(variable){
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if(pair[0] == variable){return pair[1];}
	}
	return("");
}
function replaceFlag(updLogC){
	var updLog = myReplace(updLogC,'【新增】','<span class="layui-badge layui-bg-green">新增</span> &nbsp;&nbsp;');
	updLog = myReplace(updLog,'【修复】','<span class="layui-badge layui-bg-orange">修复</span> &nbsp;&nbsp;');
	updLog = myReplace(updLog,'【优化】','<span class="layui-badge layui-bg-blue">优化</span> &nbsp;&nbsp;');
	updLog = myReplace(updLog,'【其他】','<span class="layui-badge layui-bg-black">其他</span> &nbsp;&nbsp;');
	updLog = myReplace(updLog,'【删除】','<span class="layui-badge layui-bg-red">删除</span> &nbsp;&nbsp;');
	return updLog;
}
function replaceHr(updLogC){
	var updLog = myReplace(myReplace(updLogC,'\r\n','<br>'),'\n','<br>');
	return updLog;
}
var skey= getQueryVariable("skey");
if(skey == ''){
	window.location.replace(error_url);
}
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', server_url + 'web/getUpdateLog?skey=' + skey, true);
httpRequest.send();
httpRequest.onreadystatechange = function () {
	if (httpRequest.readyState == 4 && httpRequest.status == 200) {
		var ret = httpRequest.responseText;
		var json = JSON.parse(ret);
		var result = json.result;
		var softName = result.softName;
		var updlogList = result.updlogList;
		var html = '<title>' + softName + ' - 更新日志</title><meta name="renderer" content="webkit"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><link rel="stylesheet" href="http://mycdn.daenx.cn/updateLog/css/layui.css" media="all"><link rel="shortcut icon" type="image/x-icon" href="http://mycdn.daenx.cn/updateLog/favicon.ico" /></head><body style="padding:20px;max-width:700px;margin:0 auto;"><fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">  <legend>๑乛◡乛๑卡在了奇怪的地方</legend></fieldset>      <center><a href="#"><button type="button" class="layui-btn layui-btn-normal layui-btn-radius">' + softName +'</button></a><br></center><fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;"><legend>更新日志</legend></fieldset><ul class="layui-timeline">  ';
		var log = '';
		var huo = '';
		var yuan = '';
		var emoji = '💗';
		var xiao = '😃';
		var flag = xiao;
		for (element of updlogList){
		  log = log + '<li class="layui-timeline-item"><i class="layui-icon layui-timeline-axis">' + flag + '</i><div class="layui-timeline-content layui-text"><h3 class="layui-timeline-title">Ver:' + element.ver + '&nbsp;&nbsp;' +timestampToTime( element.upd_time) + '</h3>' + replaceHr(replaceFlag(element.upd_log));
		}
		html = html + log;
		html = html + '</ul>       ';
		html = html + "</body></html>";
		document.write(html);
	}
};
</script>

